﻿
using HBase;
using HBase.cache;
using hCommand;
using hCommand.entity; 
using System; 
using System.Data.SqlClient;

namespace hCommand {
    [RoutePrefix("api/user")]
    public class UserServe : BaseApiController {

        string connectName = "main";
        ISysServer sysServer = WMSDalFactray.getDal<ISysServer>();
        [HttpGet, Route("load/{openid}")]
        public CyUser load(string openid) {
            CyUser u = MyCache.getValue<CyUser>("User", openid);
            if (u == null) {

                CyUser user = new CyUser();
                user.id = WMSIdUtil.getId();

                user.openId = openid;
                user.time = DateTime.Now;

                string suffix = HUtil.hashCode(openid);
                user.suffix = suffix + "@" + connectName;

                sysServer.insert(BaseConfig.BaseDBConnStr, user);
                sysServer.runProcedure(connectName, "create_equp_use", new SqlParameter("myname", suffix));
                sysServer.runProcedure(connectName, "create_recharge", new SqlParameter("myname", suffix));
     
            }

            return u;
        }





    }
}
